<template>
  <div class="home">
    <!-- 搜索框组件 -->
    <div class="topsearch">
      <router-link :to="{path :'/mysearch'}">
        <div class="inputbox">
        <div class="inp"><input type="text" placeholder="惊涛骇浪"></div>
        <div class="searchicon"><img src="../assets/搜索.png" alt=""></div>
      </div>
      </router-link>
      
    </div>
    <van-tabs v-model="active">
      <van-tab title="精选">
        <jing-xuan></jing-xuan>
      </van-tab>
      <van-tab title="免费">
        <mian-fei></mian-fei>
      </van-tab>
      <van-tab title="男生">
        <nan-sheng></nan-sheng>
      </van-tab>
      <van-tab title="女生">
        <nv-sheng></nv-sheng>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
// 导入四个组件
import JingXuan from "./JingPing.vue";
import MianFei from "./MianFei.vue";
import NanSheng from "./NanSheng.vue";
import NvSheng from "./NvSheng.vue";
// 导入get方法
import {get} from '../http/request'
export default {
  name: "HomeView",
  components: {
    JingXuan,
    MianFei,
    NanSheng,
    NvSheng,
  },
  data() {
    return {
      active: 0,
    };
  },
  methods: {
    async getmydata(){
      await get(`https://apis.netstart.cn/yunyuedu/reader/book/info.json?source_uuid=3327685ee3514bd7a89f8f78f0785e54_4`)
      .then(
        data=>{
          console.log(data);
        }
      )
    }
  },
  // 初始化
  created(){
    this.getmydata();
  }
};
</script>

<style lang="scss" scoped>
.home {
  width: 100%;
  margin-top: 5px;
  font-size: 16px;
  .topsearch {
    width: 100%;
    position: relative;
    .inputbox {
      width: 100%;
      height: 40px;
      display: flex;
      .inp {
        width: 300px;
        height: 40px;
        // background-color: gray;
        margin-left: 20px;
        input {
          width: 300px;
          height: 40px;
          background-color: #EFECEC;
          border-radius: 20px;
          padding-left: 20px;
          // margin-top: 5px;
        }
      }
      .searchicon {
        width: 30px;
        height: 30px;
        // background-color: green;
        position: absolute;
        right: 25px;
        top: 8px;
        img {
          width: 30px;
          height: 30px;
        }
      }
    }
  }
  
}
</style>